package com.jingtai.platform.controller.supply;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.supply.SupplyGoods;
import com.jingtai.platform.service.supply.SupplyGoodsService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 供应商商品表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:32
 */
@Validated
@RestController
@RequestMapping("/platform/supplygoods")
@Api(tags = "供应商商品表")
public class SupplyGoodsController{

    @Autowired
    private SupplyGoodsService supplyGoodsService;


    @ApiOperation("供应商商品表列表查询")
    @GetMapping("/list")
    public ResultUtil aopSupplyGoodsList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return supplyGoodsService.SupplyGoodslist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询supplyGoods实体")
    @GetMapping("/getSupplyGoodsById")
    public ResultUtil GetSupplyGoodsById(@CApiParam(name = "id",value = "supplyGoods实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return supplyGoodsService.getSupplyGoodsById(id);
    }


    @ApiOperation("新增supplyGoods实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"supplyGoods.id","supplyGoods.createTime","supplyGoods.updateTime","supplyGoods.deleteFlag"})
    public ResultUtil aopAddSupplyGoods(@RequestBody @Validated({BaseEntity.Create.class}) SupplyGoods supplyGoods){
        return supplyGoodsService.addSupplyGoods(supplyGoods);
    }

    @ApiOperation("编辑supplyGoods实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"supplyGoods.createTime","supplyGoods.updateTime","supplyGoods.deleteFlag"})
    public ResultUtil aopEditSupplyGoods(@RequestBody @Validated({BaseEntity.Update.class}) SupplyGoods supplyGoods){
        return supplyGoodsService.editSupplyGoods(supplyGoods);
    }

    @ApiOperation("根据ID删除supplyGoods实体")
    @GetMapping("/delSupplyGoodsById")
    public ResultUtil aopDelSupplyGoodsById(@CApiParam(name = "id",value = "supplyGoods实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return supplyGoodsService.delSupplyGoodsById(id);
    }

}






